import org.apache.hadoop.hbase.client.ConnectionFactory;

import java.sql.*;

public class Demo8PhoenixJDBC {
    public static void main(String[] args) throws SQLException {
        Connection conn = DriverManager.getConnection("jdbc:phoenix:master,node1,node2:2181");
        PreparedStatement ps = conn.prepareStatement("select /*+ INDEX(DIANXIN DIANXIN_INDEX) */ * from DIANXIN where end_date = ?");
        ps.setString(1, "20180502235159");
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            String col1 = rs.getString(1);
            String col2 = rs.getString(2);
            String col3 = rs.getString(3);
            String col4 = rs.getString(4);
            String col5 = rs.getString(5);
            System.out.println(col1 + "\t" + col2 + "\t" + col3 + "\t" + col4 + "\t" + col5);
        }
        rs.close();
        ps.close();
        conn.close();
    }
}
